<?php
/* 
 * ebiz front
 * 
 * CategoryDao Model
 * 
 * @author allen
 * 
 */
require_once '../app/core/models/BaseDao.php';
require_once '../app/core/db/DBUtil.class.php';

class CategoryDao extends BaseDao 
{
	
    private $tableName = "categories";   
    
    public function __construct($dbUtil){ 
        parent::__construct($dbUtil);
    } 
    
    public function getById($id){   //used in category page bread crumb
        $param = array($id);
        $sql = "select * from $this->tableName where id = ? and is_delete = 0 and visible = 1 ";
        return $this->dbUtil->SelectData($sql, $param);
    }
    
    public function getAllCategory(){   //not used
        $param = array();
        $sql = "select * from $this->tableName where is_delete = 0 and visible = 1 ";
        return $this->dbUtil->SelectData($sql, $param);
    }
    
    public function getByParentId($parentId){  //in category Service find parent_id in recursion function (ajax used)
        $param = array($parentId);
        $sql = "select * from $this->tableName where parent_id = ? and is_delete = 0 and visible = 1 ";
        return $this->dbUtil->SelectData($sql, $param);
    }
    
    public function getByUrlTitle($urlTitle){   //in category Service to find cid 
        $param = array($urlTitle);
        $sql = "select * from $this->tableName where lower(url_title) = ? and is_delete = 0 and visible = 1 ";
        return $this->dbUtil->SelectData($sql, $param);
    }
    
    
}



